< previous page page_344 next page >

Page 344
Table 15.1 Important Ambient Properties
PropertyDescription
BackColorHolds the container's background color.
DisplayAsDefaultIndicates whether a user-drawn control is the default control in the container.
DisplayNameHolds the name of the control instance. You can use the DisplayName property to identify the messages presented to the developer at designtime.
FontRepresents the font of the container.
ForeColorHolds the foreground color of the container.
LocaleIDIndicates the locale in which the control is running. In international programs, this property is useful for changing the language or date formats.
TextAlignRepresents the container's text alignment setting.
UserModeIndicates whether the control is running at designtime or runtime. A UserMode value of False indicates designtime; True indicates runtime. Another property, UIDead, indicates break mode.

You can access each of the properties in Table 15.1 from within the control by using the Ambient object.
Introducing the Extender Object
In addition to the properties provided by the Ambient object, there is a separate object known as the Extender object, which provides some other useful properties. These properties, called extender properties, at first glance appear to be part of a control instance. For example, when you place a control on a form, the Left and Top properties look like they are part of that control. However, in reality, these properties and several others are part of the Extender object.
Although the Ambient and Extender objects both provide information about a control in relation to its container, the Extender object is not available until the control has been sited (placed) on its container. Because each container is different, you cannot determine in advance what the container is or which properties it will support. For this reason, you can't access the Extender object in a control's Initialize event procedure, which is called before the control is completely sited on its container. However, you can access the Extender object in the InitProperties and ReadProperties events.
To view the extender properties, draw an instance of the sample control on a form, and press F4 to display the Properties window. Notice that even though you have not added any properties to the user control, several are already listed. They are the properties of the Extender object.

 
< previous page page_344 next page >